package com.bjx.common.mybatis.plus.util;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;
/**
 * @desc: 转换工具类
 * @author: liushuai
 * @date: 2022/8/15 16:03
 */
public class ConvertUtil {
    public static <T> IPage <T> toPage(Class<T> type, IPage page){
        List<T> typeList = Convert.toList(type,page.getRecords());
        IPage<T> iPage = new Page<>();
        iPage.setCurrent(page.getCurrent());
        iPage.setSize(page.getSize());
        iPage.setRecords(typeList);
        iPage.setTotal(page.getTotal());
        return  iPage;
    }
}
